package com.example.newnoke.ui;

import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.newnoke.R;
import com.example.newnoke.data.YeJi2Data;
import com.example.newnoke.databinding.ActivityYeji2Binding;
import com.example.newnoke.mvp.presenter.ZhuanPresenter;
import com.example.newnoke.mvp.view.IZhuanV;
import com.example.newnoke.utils.API;
import com.geya.jbase.baseactivity.BaseRVActivity;
import com.geya.jbase.constant.RequestType;

import java.util.HashMap;
import java.util.List;

public class YeJiActivity2 extends BaseRVActivity<YeJi2Data.DataBean, ZhuanPresenter> implements IZhuanV {


    private ActivityYeji2Binding mBinding;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mBinding = DataBindingUtil.setContentView(this, R.layout.activity_yeji2);

        initBaseView();
        mTitleButton.setTitles("罗科链业绩");
        mBinding.tv.setText("我的业绩：￥" + getIntent().getStringExtra("price"));
        initRV(0, 0);

        HashMap<String, Object> map = new HashMap<>();
        requestData(RequestType.OKGO_POST, RequestType.ADDRESS, API.CHILD_CHAINS, YeJi2Data.class, map);
    }

    @Override
    public void pay(String s, boolean bl) {

    }

    @Override
    public ZhuanPresenter newP() {
        return new ZhuanPresenter(this);
    }

    @Override
    public Class setClass() {
        return YeJi2Data.DataBean.class;
    }

    @Override
    public BaseQuickAdapter initAdapter(List<YeJi2Data.DataBean> list) {
        return new BaseQuickAdapter<YeJi2Data.DataBean, BaseViewHolder>(R.layout.item_list_yeji2, list) {

            @Override
            protected void convert(BaseViewHolder helper, YeJi2Data.DataBean item) {
                helper.setText(R.id.name, item.getTitle())
                ;

            }
        };
    }

    @Override
    protected void onListItemClick(YeJi2Data.DataBean object, int position) {
        super.onListItemClick(object, position);
        startActivity(new Intent(YeJiActivity2.this, YJJLActivity.class)
                .putExtra("level", object.getLevel() + "".trim()));
    }
}
